home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE23 / SURVIVE / uBase.pas < prev   
Pascal/Delphi Source File  |  1997-05-19  |  1KB  |  65 lines

  1. unit uBase;
  2.  
  3. interface
  4.  
  5. uses
  6.   Classes;
  7.  
  8. const
  9.   mskCurrency = '%.0m';   { whole unit currency }
  10.  
  11. type
  12.   TAmountsList = class(TList)
  13.     { This is a generic class that manages a list of dollar amounts (stored
  14.       as LongInts). }
  15.   protected
  16.     function GetItem(aIndex: Integer): LongInt;
  17.     procedure SetItem(aIndex: Integer; aValue: LongInt);
  18.   public
  19.     procedure Add(aValue: LongInt);
  20.     procedure Assign(aSource: TAmountsList);
  21.     procedure ZeroOut;
  22.     property Items[aIndex: Integer]: LongInt read GetItem write SetItem; default;
  23.   end;
  24.  
  25.  
  26. implementation
  27.  
  28. { TAmountsList }
  29.  
  30. function TAmountsList.GetItem(aIndex: Integer): LongInt;
  31. begin
  32.   Result := 0;
  33.   if aIndex < Count then
  34.     Result := LongInt(inherited Items[aIndex]);
  35. end;
  36.  
  37. procedure TAmountsList.SetItem(aIndex: Integer; aValue: LongInt);
  38. begin
  39.   inherited Items[aIndex] := Pointer(aValue);
  40. end;
  41.  
  42. procedure TAmountsList.Add(aValue: LongInt);
  43. begin
  44.   inherited Add(Pointer(aValue));
  45. end;
  46.  
  47. procedure TAmountsList.Assign(aSource: TAmountsList);
  48. var
  49.   I: Integer;
  50. begin
  51.   Clear;
  52.   for I := 0 to aSource.Count - 1 do
  53.     Add(aSource.Items[I]);
  54. end;
  55.  
  56. procedure TAmountsList.ZeroOut;
  57. var
  58.   I: Integer;
  59. begin
  60.   for I := 0 to Count - 1 do
  61.     Items[I] := 0;
  62. end;
  63.  
  64. end.
  65.